load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target")
load("@fbcode_macros//build_defs:cpp_benchmark.bzl", "cpp_benchmark")
load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest")

oncall("fbcode_entropy_wardens_folly")

fbcode_target(
    _kind = cpp_unittest,
    name = "arena_test",
    srcs = ["ArenaTest.cpp"],
    headers = [],
    labels = ["oss-broken"],
    deps = [
        "//folly:memory",
        "//folly:random",
        "//folly/memory:arena",
        "//folly/memory:mallctl_helper",
        "//folly/memory:malloc",
        "//folly/portability:gflags",
        "//folly/portability:gtest",
    ],
    external_deps = [
        "glog",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "mallctl_helper_test",
    srcs = ["MallctlHelperTest.cpp"],
    headers = [],
    allocator = "jemalloc_debug",
    supports_static_listing = False,
    deps = [
        "fbsource//third-party/jemalloc:headers",
        "//folly:c_portability",
        "//folly/init:init",
        "//folly/memory:mallctl_helper",
        "//folly/memory:malloc",
        "//folly/portability:gtest",
        "//folly/portability:sys_types",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "malloc_test",
    srcs = ["MallocTest.cpp"],
    headers = [],
    deps = [
        "//folly/memory:malloc",
        "//folly/portability:gtest",
        "//folly/portability:malloc",
        "//folly/test:test_utils",
    ],
)

fbcode_target(
    _kind = cpp_benchmark,
    name = "malloc_benchmark",
    srcs = ["MallocBenchmark.cpp"],
    headers = [],
    deps = [
        "//folly:benchmark",
        "//folly:random",
        "//folly/memory:malloc",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "memory_resource_test",
    srcs = ["MemoryResourceTest.cpp"],
    headers = [],
    deps = [
        "//folly/memory:memory_resource",
        "//folly/portability:gtest",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "not_null_test",
    srcs = [
        "not_null_test.cpp",
    ],
    supports_static_listing = False,
    target_compatible_with = ["fbcode//opensource/macros:broken-in-oss"],
    deps = [
        "//folly/memory:not_null",
        "//folly/portability:gtest",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "reentrant_allocator_test",
    srcs = ["ReentrantAllocatorTest.cpp"],
    deps = [
        "//folly:utility",
        "//folly/functional:invoke",
        "//folly/memory:reentrant_allocator",
        "//folly/portability:gtest",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "sanitize_address_test",
    srcs = ["SanitizeAddressTest.cpp"],
    deps = [
        "//folly/lang:new",
        "//folly/memory:sanitize_address",
        "//folly/portability:gtest",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "sanitize_leak_test",
    srcs = ["SanitizeLeakTest.cpp"],
    deps = [
        "//folly/memory:sanitize_leak",
        "//folly/portability:gtest",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "shared_from_this_ptr_test",
    srcs = ["shared_from_this_ptr_test.cpp"],
    deps = [
        "//folly/memory:shared_from_this_ptr",
        "//folly/portability:gtest",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "thread_cached_arena_test",
    srcs = ["ThreadCachedArenaTest.cpp"],
    headers = [],
    deps = [
        "//folly:benchmark",
        "//folly:memory",
        "//folly:range",
        "//folly/lang:align",
        "//folly/memory:thread_cached_arena",
        "//folly/portability:gtest",
    ],
    external_deps = [
        "glog",
    ],
)

fbcode_target(
    _kind = cpp_unittest,
    name = "uninitialized_memory_hacks_test",
    srcs = [
        "UninitializedMemoryHacksODR.cpp",
        "UninitializedMemoryHacksTest.cpp",
    ],
    deps = [
        "//folly:random",
        "//folly/memory:uninitialized_memory_hacks",
        "//folly/portability:gtest",
    ],
    external_deps = [
        "glog",
    ],
)
